package com.huowei.htzy.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bigkoo.convenientbanner.holder.Holder;
import com.bumptech.glide.Glide;
import com.huowei.htzy.R;
import com.huowei.htzy.modle.Item;

/**
 * Created by huowei on 2016/9/19.
 */
public class NetworkImageHolderView implements Holder<Item> {
    private ImageView imageView;
    @Override
    public View createView(Context context) {
        //你可以通过layout文件来创建，也可以像我一样用代码创建，不一定是Image，任何控件都可以进行翻页
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setLayoutParams(params);
//        Animation animation = AnimationUtils.loadAnimation(context,R.anim.item_anim);
//        imageView.setAnimation(animation);
//        animation.start();
        return imageView;
    }

    @Override
    public void UpdateUI(Context context,int position, Item data) {
        imageView.setImageResource(R.mipmap.ic_launcher);
        Glide.with(context).load(data.getImage()).into(imageView);
    }
}
